package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.Game;

/**
 * 
 * @author 
 *
 */
@DAO
public interface GameDAO{
	
	@SQL("SELECT * FROM Game WHERE deleteFlag=1 #if(:t.name!=''){and name like '%##(:t.name)%' } #if(:t.type!='-1'){and type = :t.type } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Game> query(@SQLParam("t") Game game);
	
	@SQL("SELECT count(1) FROM Game WHERE deleteFlag=1 #if(:t.name!=''){and name like '%##(:t.name)%' } #if(:t.type!='-1'){and type = :t.type } ")
    int querySize(@SQLParam("t") Game game);
    
    @SQL("SELECT * FROM Game WHERE id=:1")
    Game queryById(int id);
    
    @SQL("INSERT INTO Game (img,name,type,descs,url,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.img,:t.name,:t.type,:t.descs,:t.url,1,now(),:t.createUser,now(),:t.updateUser)")
    void create(@SQLParam("t") Game game);
	
	@SQL("UPDATE Game SET url=:t.url,img=:t.img,name=:t.name,type=:t.type,descs=:t.descs,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") Game game);
    
    @SQL("UPDATE Game SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}